package com.example.demo.web.controller;

import com.example.demo.domain.base.BaseResult;
import com.example.demo.domain.base.PageParam;
import com.example.demo.domain.base.PageResult;
import com.example.demo.domain.param.CheckInCreateParam;
import com.example.demo.domain.param.CheckInUpdateParam;
import com.example.demo.domain.param.GiftGivingCreateParam;
import com.example.demo.domain.param.GiftGivingUpdateParam;
import com.example.demo.domain.vo.CheckInVO;
import com.example.demo.domain.vo.GiftGivingVO;
import com.example.demo.service.CheckInService;
import com.example.demo.service.GiftGivingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * PointsController
 *
 * @author haochen78
 * @date 2025/10/3 21:13
 **/
@RestController
@RequestMapping("/points")
public class PointsController {

    @Autowired
    private CheckInService checkInService;
    @Autowired
    private GiftGivingService giftGivingService;

    @PostMapping("/check-in-list")
    public BaseResult<PageResult<CheckInVO>> listCheckIns(@RequestBody PageParam param) {
        return BaseResult.success(checkInService.listCheckIns(param));
    }

    @PostMapping("/check-in-add")
    public BaseResult<Void> createCheckIn(@RequestBody CheckInCreateParam param) {
        checkInService.checkInAdd(param);
        return BaseResult.success();
    }


    @PutMapping("/check-in-update")
    public BaseResult<Void> updateCheckIn(@RequestBody CheckInUpdateParam param) {
        checkInService.checkInUpdate(param);
        return BaseResult.success();
    }

    @DeleteMapping("/check-in-delete/{id}")
    public BaseResult<Void> deleteCheckIn(@PathVariable Long id) {
        checkInService.checkInDelete(id);
        return BaseResult.success();
    }


    @PostMapping("/gift-giving-list")
    public BaseResult<PageResult<GiftGivingVO>> listGiftGivings(@RequestBody PageParam param) {
        return BaseResult.success(giftGivingService.listGiftGivings(param));
    }

    @PostMapping("/gift-giving-add")
    public BaseResult<Void> createGiftGiving(@RequestBody GiftGivingCreateParam param) {
        giftGivingService.createGiftGiving(param);
        return BaseResult.success();
    }


    @PutMapping("/gift-giving-update")
    public BaseResult<Void> updateGiftGiving(@RequestBody GiftGivingUpdateParam param) {
        giftGivingService.updateGiftGiving(param);
        return BaseResult.success();
    }

    @DeleteMapping("/gift-giving-delete/{id}")
    public BaseResult<Void> deleteGiftGiving(@PathVariable Long id) {
        giftGivingService.deleteGiftGiving(id);
        return BaseResult.success();
    }
}
